<template>
	<view class="template-group tn-safe-area-inset-bottom">
		<tn-nav-bar fixed customBack :bottomShadow="false" id="navbar">
			<view slot="back" class='tn-custom-nav-bar__back'>
				<text class='icon tn-icon-left' @click="goBack"></text>
				<text class='icon tn-icon-discover-fill' @click="goHome"></text>
			</view>
			<view class="tn-flex tn-flex-col-center tn-flex-row-center">
				<view class="tn-text-bold tn-text-xl">历史动态</view>
			</view>
		</tn-nav-bar>
		<view class="list tn-margin-bottom-xl" :style="{paddingTop: vuex_custom_bar_height + 'px'}">
				<!-- 图文信息 -->
			<view v-for="(item,index) in content" :key="index">
				<view class="blogger__item">
					<view class="blogger__author tn-flex tn-flex-row-between tn-flex-col-center">
						<view class="justify__author__info">
							<view class="tn-flex tn-flex-row-center">
								<view class="tn-flex tn-flex-row-center tn-flex-col-center"
									@click.stop="tn('/circlePages/businessCard?id='+item.mpiid)">
									<view class="">
										<tn-avatar class="" shape="circle" :src="item.userAvatar" size="lg">
										</tn-avatar>
									</view>
									<view class="tn-padding-right tn-text-ellipsis">
										<view class="tn-padding-right tn-padding-left-sm tn-text-bold tn-text-lg">
											{{ item.userName }}
										</view>
										<view
											class="tn-padding-right tn-padding-left-sm tn-padding-top-xs tn-color-gray">
											{{ item.date }}
										</view>
									</view>
								</view>
							</view>
						</view>
						<!-- <view
							class="blogger__author__btn justify-content-item tn-flex-col-center tn-flex-row-center">
							<text class="tn-icon-more-vertical tn-color-gray tn-text-bold tn-text-xxl"></text>
						</view> -->
					</view>

					<view
						class="blogger__desc tn-margin-top-sm tn-margin-bottom-sm tn-text-justify  tn-flex-col-center tn-flex-row-left"
						@click="tn('/circlePages/details?iid='+item.iid)">
						<view v-for="(label_item,label_index) in item.label" :key="label_index"
							class="blogger__desc__label tn-float-left tn-margin-right tn-bg-gray--light tn-round tn-text-sm tn-text-bold">
							<text class="blogger__desc__label--prefix">#</text>
							<text class="tn-text-df">{{ label_item }}</text>
						</view>
						<!-- 不用限制长度了，因为发布的时候限制长度了-->
						<text v-if="!item.label || item.label.length < 4"
							class="blogger__desc__content tn-flex-1 tn-text-justify tn-text-df">{{ item.desc }}</text>
					</view>

					<block v-if="item.mainImage">
						<view v-if="[1,2,4].indexOf(item.mainImage.length) != -1" class="tn-padding-top-xs"
							@click="tn('/circlePages/details?iid='+item.iid)">
							<image v-for="(image_item,image_index) in item.mainImage" :key="image_index"
								class="blogger__main-image" :class="{
				'blogger__main-image--1 tn-margin-bottom-sm': item.mainImage.length === 1,
				'blogger__main-image--2 tn-margin-right-sm tn-margin-bottom-sm': item.mainImage.length === 2 || item.mainImage.length === 4
			  }" :src="image_item" mode="aspectFill"></image>
						</view>
						<view v-else class="tn-padding-top-xs" @click="tn('/circlePages/details?iid='+item.iid)">
							<tn-grid hoverClass="none" :col="3">
								<block v-for="(image_item,image_index) in item.mainImage" :key="image_index">
									<!-- #ifndef MP-WEIXIN -->
									<tn-grid-item style="width: 30%;margin: 10rpx;">
										<image class="blogger__main-image blogger__main-image--3" :src="image_item"
											mode="aspectFill"></image>
									</tn-grid-item>
									<!-- #endif-->
									<!-- #ifdef MP-WEIXIN -->
									<tn-grid-item style="width: 30%;margin: 10rpx;">
										<image class="blogger__main-image blogger__main-image--3" :src="image_item"
											mode="aspectFill"></image>
									</tn-grid-item>
									<!-- #endif-->
								</block>
							</tn-grid>
						</view>
					</block>

					<!-- <view class="tn-flex tn-flex-row-between tn-flex-col-center tn-margin-top-xs">
						<view class="justify-content-item tn-color-gray tn-text-center">
							<view class="">
								<text class="blogger__count-icon tn-icon-footprint"></text>
								<text class="tn-padding-right">{{ item.collectionCount }}</text>
								<text class="blogger__count-icon tn-icon-message"></text>
								<text class="tn-padding-right">{{ item.commentCount }}</text>
								<text class="blogger__count-icon tn-icon-like"></text>
								<text class="">{{ item.likeCount }}</text>
							</view>
						</view>
						<view class="justify-content-item tn-flex tn-flex-col-center">
							<view style="margin-right: 10rpx;margin-left: 20rpx;">
								<tn-avatar-group :lists="item.viewUser.latestUserAvatar"
									size="sm"></tn-avatar-group>
							</view>
							<text class="tn-color-gray">{{ item.viewUser.viewUserCount }}人</text>
						</view>
					</view> -->
					<view class="tn-flex tn-flex-row-between tn-flex-col-center tn-margin-top-xs">
						<view class="justify-content-item tn-color-gray tn-text-center">
							<view style="margin-right: 10rpx;margin-left: 20rpx;">
								<tn-avatar-group :lists="item.viewUser.latestUserAvatar" size="sm"></tn-avatar-group>
							</view>
							<!-- <text class="tn-color-gray">{{ item.viewUser.viewUserCount }}人</text> -->
						</view>
						<view class="justify-content-item tn-flex tn-flex-col-center">
							<view class="justify-content-item tn-flex tn-flex-col-center">
								<button type="default" open-type="share" class="shareBtn" :data-id="item.iid"
									data-type="dongtai" @click.stop="">
									<text class="blogger__count-icon tn-icon-share"></text>
								</button>
								<!-- <text class="tn-padding-right">{{ item.collectionCount }}</text> -->
								<text class="blogger__count-icon tn-icon-message"></text>
								<text class="tn-padding-right">{{ item.commentCount }}</text>
								<text class="blogger__count-icon tn-icon-like" @click.stop="dianzan(item)"></text>
								<text class="">{{ item.likeCount }}</text>
								<!-- <button type="default" open-type="share" class="shareBtn" :data-id="item.iid"
									data-type="dongtai" @click.stop="">
									<text class="blogger__count-icon tn-icon-share"></text>
								</button> -->
							</view>
						</view>
					</view>
				</view>

				<!-- 边距间隔 -->
				<view class="tn-strip-bottom" v-if="index != content.length - 1"></view>
			</view>
		</view>
	</view>
</template>

<script>
	import Tools from '@/tools/config.js'
	import template_page_mixin from '@/libs/mixin/template_page_mixin.js'
	export default {
		mixins: [template_page_mixin],
		data() {
			return {
				content:[],
				pages:"1",
				id:"",
			}
		},
		onLoad(options){
			this.id = options.id
		},
		onShow(){
			this.pages = 1
			this.content = []
			this.initData()
		},
		onReachBottom() {
			this.pages++
			this.getTrendList()
		},
		methods: {
			tn(e) {
				uni.navigateTo({
					url: e,
				});
			},
			initData(){
				this.getTrendList()
			},
			getTrendList() {
				let theopenid = uni.getStorageSync('openid')
				let theunionid = uni.getStorageSync('unionid')
				uni.request({
					url: Tools.host + '/wshly.ashx',
					method: 'POST',
					data: {
						'lx': 'dongtai_qzsy_ls',
						'openid': theopenid,
						'unionid': theunionid,
						'quniid': this.id || "",
						'pagesize': 20,
						'pageindex': this.pages
					},
					success: (res) => {
						//成功
						if (res.data.return_code == '1') {
							// console.log("1111",a,a.sltximg)
							const a = JSON.parse(res.data.data)
							this.content = this.content.concat(a)
							console.log("2222222", a)
						}
					},
					fail: (res) => {
						console.log('失败' + res)
						uni.showModal({
							title: '失败，请稍后重试',
							showCancel: false
						})
					}
				});
			},
		}
	}
</script>

<style lang="scss" scoped>
	.shareBtn {
		display: inline-flex;
		background-color: unset;
		line-height: unset;
	}
	
	.shareBtn::before {
		all: unset;
	}
	
	.shareBtn::after {
		all: unset;
	}
	
	
	.list{
		flex:1;
		padding: 0 30rpx;
	}

	.tn-custom-nav-bar__back {
		width: 100%;
		height: 100%;
		position: relative;
		display: flex;
		justify-content: space-evenly;
		align-items: center;
		box-sizing: border-box;
		background-color: rgba(0, 0, 0, 0.03);
		border-radius: 1000rpx;
		border: 1rpx solid rgba(255, 255, 255, 0.5);
		// color: #FFFFFF;
		font-size: 18px;

		.icon {
			display: block;
			flex: 1;
			margin: auto;
			text-align: center;
		}

		&:before {
			content: " ";
			width: 1rpx;
			height: 110%;
			position: absolute;
			top: 22.5%;
			left: 0;
			right: 0;
			margin: auto;
			transform: scale(0.5);
			transform-origin: 0 0;
			pointer-events: none;
			box-sizing: border-box;
			opacity: 0.05;
			background-color: #000000;
		}
	}



</style>